package com.bruce.mqProducer.service;

import com.bruce.mqProducer.entity.Order;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by bruce on 19/1/8 -- 15:57
 */
@Component
public class OrderSender {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(Order order) {
        String exchange = "order-exchange";
        String routingKey = "order.hello";
        rabbitTemplate.convertAndSend(exchange, routingKey, order);
    }
}
